function buttonEve(partment){
  if(partment=='savebtn'){

   if(editFlag==true)
   {
     if(mode=="add" && saveFlg==true)
     {
        alert("当前文档已保存,不能重复保存!");
        return false;
     }
     if(tXML.getProgressFlg()!="4"){
        document.getElementById("out").innerHTML=tXML.getProgressText()+"系统正在处理你的请求,请稍后再点击保存!";
        return false;
     }
     if (!checkData()){
      return false;
     }

     xmldoc();
     if (saveFlg==true){
     changeReadOnly(true);
       return true
     }
     else{
       return false
     }
   }else
   {
     alert("当前文档没有编辑,不可保存!");
   }
  }
  if(partment=="editbtn")
  {
    if (mode2 != "add"){
      if(!requestEditLock()) return;
    }
     changeReadOnly(false);
     saveFlg = false;
     editFlag=true;
     mode="edit";
     return true
  }

  if(partment=="nextbtn")
  {

    if (mode=="add" && saveFlg==false){
      //执行下一步以前先保存文档
      if (buttonEve("savebtn")){
        parent.location.href="/WfcCTR_NextStep?action=startNextStep&title=" + form1.title.value+ "&isSearch="+isSearch;
        return true;
      }
      else{
        return false;
      }
    }
    else{
      if (saveFlg==false){
        if (buttonEve("savebtn")){
          parent.location.href="/WfcCTR_NextStep?action=startNextStep&title=" + form1.title.value+ "&isSearch="+isSearch;
          return true;
        }
        else{
          return false;
        }
      }
      else{
        parent.location.href="/WfcCTR_NextStep?action=startNextStep&title=" + form1.title.value+ "&isSearch="+isSearch;
        return true
      }
    }
  }

  if(partment=="exit")
  {
    if (!saveFlg){
      if (confirm("文档已经编辑，是否保存？")){
        if (!buttonEve("savebtn"))
        {
          return false;
        }
      }
    }
    //history.back()
    if (parent.openSource == "P"){
      parent.location = "/serviceLocator?action=navControl&typeCode=1&isSearch="+isSearch;
    }
    else{
      parent.location = "/serviceLocator?action=modEntry&url=/AppUI/Qsps/AppUI_QSPS_Grid.jsp&typeCode=QSPS&isSearch="+isSearch;
    }
  }

}

//检测域值是否是整数
function isNumberFloat(inputString){
  return (!isNaN(parseInt(inputString))) ? true : false;
}

  //去掉空格
function Trim(str){
  if(str.charAt(0) == " "){
    str = str.slice(1);
    str = Trim(str);
  }
  return str;
}
//校验
function checkData(){
  if (QSDX.getOrgCount()<1)
  {
	alert("请选择请示对象！")
    return false;
  }
  if (Trim(document.form1.title.value) == ""){
    alert("请输入请示标题！")
    return false;
  }
  if (Trim(document.form1.content.value) == ""){
    alert("请输入请示事由！")
    return false;
  }
  return true
}